package com.tarena.util;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import sun.misc.BASE64Encoder;

public class MD5Util {
	public static void main(String[] args) {
		System.out.println(getValue("123"));
	}
	//把密码生成摘要
	public static String getValue(String pwd) {
		String password = null;
		try {
			MessageDigest md = MessageDigest.getInstance("md5");
			byte[] buf = md.digest(pwd.getBytes());
			BASE64Encoder encoder = new BASE64Encoder();
			password = encoder.encode(buf);

		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
		}
		return password;
	}
}
